import { Button, Popconfirm } from 'antd'
import { ClearOutlined } from '@ant-design/icons'
import { useWorkTime } from '../../contexts/WorkTimeContext'
import ExcelImport from '../../components/ExcelImport'

const DataImportSection = () => {
  const { 
    workTimeData, 
    loading, 
    handleImportData, 
    handleClearAllData 
  } = useWorkTime()

  return (
    <div className='section-card' style={{ height: '100%' }}>
      <div
        style={{
          display: 'flex',
          justifyContent: 'space-between',
          alignItems: 'center',
          marginBottom: '16px',
        }}
      >
        <h2 className='section-title' style={{ marginBottom: 0 }}>
          数据导入
        </h2>
        {workTimeData.length > 0 && (
          <Popconfirm
            title='确定要清除所有数据吗？'
            description='此操作不可恢复，请确认。'
            onConfirm={handleClearAllData}
            okText='确定'
            cancelText='取消'
          >
            <Button danger icon={<ClearOutlined />}>
              清除所有数据
            </Button>
          </Popconfirm>
        )}
      </div>
      <ExcelImport onImportData={handleImportData} loading={loading} />
    </div>
  )
}

export default DataImportSection 